pimpas.FireBug = Class.create( );
pimpas.Extends(pimpas.FireBug, pimpas.Object);
pimpas.Extends(pimpas.FireBug,
	{
		installLogInConsole: function(  ) {
			var filter = (arguments.length > 0) ? arguments[0] : null;
			pimpas.Log.addGlobalListener( new pimpas.FireBug.LogListener(filter) );
		}
	}
);

pimpas.FireBug.LogListener = pimpas.Listener;
pimpas.Extends(pimpas.FireBug.LogListener.prototype,
   {
	    filter: null,
	    initialize: function(filter) {
			this.id = pimpas.globalID++;
			this.log = new pimpas.Log();
			this.filter = filter;
		},
		callBack: function(ref, obj) {
			if(this.filter != null)
				if(!this.filter.apply(obj)) return;
			var h,m,s,ss;
			h = obj.time.getHours();
			m = obj.time.getMinutes();
			s = obj.time.getSeconds();
			ss = obj.time.getMilliseconds();
			var msg = "["+h+":"+m+":"+s+":"+ss+"] LEVEL: "+obj.level+" => "+obj.message;
			try {
				if(obj.level == pimpas.Log.DEBUG)					
					console.debug(msg);
				else if(obj.level == pimpas.Log.INFO)
					console.info(msg);
				else if(obj.level == pimpas.Log.ERROR || obj.level == pimpas.Log.FATAL)
					console.error(msg);
				else
					console.warn(msg);
			} catch(e){}
		}
   }
);

pimpas.FireBug.initialize( );